package net.hn.hnms.biz.plan.enums;

import cn.hutool.core.util.StrUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum MineInfo {

    GAOTOUYAO("150621011038","91150100767874571R","高头窑煤矿","北能公司"),
    LINGLU("150781013671","91150781720169744B","灵露煤矿","扎煤公司"),
    HETAOYU("621025009717","91621000566400003E","核桃峪煤矿","庆阳公司"),
    YANBEI("620824009734","916200002258722645","砚北煤矿","华亭公司"),
    WEIJIAMAO("150622004330","91150100767874571R","魏家峁煤矿","北能公司"),
    HUAJIAN("150622004317","91150100767874571R","铧尖煤矿","北能公司");

    private String companyCode;

    private String code;
    private String name;

    private String companyName;

    private static List<String>  companyNameList = new ArrayList<>();

    MineInfo(String code, String companyCode, String name, String companyName) {
        this.code = code;
        this.companyCode = companyCode;
        this.name = name;
        this.companyName = companyName;
    }

    public String getName(){
        return name;
    }

    public String getCode() {
        return code;
    }

    public String getCompanyCode() {
        return companyCode;
    }

    public String getCompanyName() {
        return companyName;
    }

    public static List<String> getCompanyNameList() {
        return companyNameList;
    }


    /**
     * 根据矿编码获取矿名称
     * @param code
     * @return
     */

    public static String getNameByCode(String code){
        MineInfo[] values = values();
        for (MineInfo value : values) {
            if(StrUtil.equalsIgnoreCase(value.getCode(),code)) return value.getName();
        }
        return null;
    }

    /**
     * 根据矿名称获取矿编码
     * @param name
     * @return
     */
    public static String getCodeByName(String name){
        MineInfo[] values = values();
        for (MineInfo value : values) {
            if(StrUtil.equalsIgnoreCase(value.getName(),name)) return value.getCode();
        }
        return null;
    }

    /**
     * 根据公司编码获取煤矿名称
     * @param companyCode
     * @return
     */
    public static List<String> getNameByCompanyCode(String companyCode){
        MineInfo[] values = values();
        for (MineInfo value : values) {
            if(StrUtil.equalsIgnoreCase(value.getCompanyCode(),companyCode)) {
                companyNameList.add(value.getName());
            }
        }
        return companyNameList;
    }

    /**
     * 根据公司编码获取煤矿信息
     * @param companyCode
     * @return
     */
    public static Map<String,String> getNameByCompanyCodeOfMap(String companyCode){
        Map<String,String> codeAndNameOfMap = new HashMap<>();
        MineInfo[] values = values();
        for (MineInfo value : values) {
            if(StrUtil.equalsIgnoreCase(value.getCompanyCode(),companyCode)) {
                codeAndNameOfMap.put(value.code,value.getName());
            }
        }
        return codeAndNameOfMap;
    }

    /**
     * 根据矿编码或矿名称获取矿信息
     * @param mineCode
     * @param mineName
     * @return
     */
    public static Map<String,String> getNameByMineCodeAndName(String companyCode,String companyName, String mineCode,String mineName){
        Map<String,String> codeAndNameOfMap = new HashMap<>();
        MineInfo[] values = values();
        for (MineInfo value : values) {
            if(mineCode!=null&&!mineCode.equals("")&&mineName!=null&&!mineName.equals("")){
                if(StrUtil.equalsIgnoreCase(value.getCompanyCode(),companyCode)&&StrUtil.equalsIgnoreCase(value.getCode(),mineCode)&&StrUtil.contains(value.getName(),mineName)) {
                    codeAndNameOfMap.put(value.code,value.getName());
                }
            }else if(mineCode!=null&&!mineCode.equals("")){
                if(StrUtil.equalsIgnoreCase(value.getCompanyCode(),companyCode)&&StrUtil.equalsIgnoreCase(value.getCode(),mineCode)) {
                    codeAndNameOfMap.put(value.code,value.getName());
                }
            }else {
                if(StrUtil.equalsIgnoreCase(value.getCompanyCode(),companyCode)&&StrUtil.contains(value.getName(),mineName)) {
                    codeAndNameOfMap.put(value.code,value.getName());
                }
            }
        }
        return codeAndNameOfMap;
    }


}
